package net.atomarrow.util.bean;

import java.util.Date;

import net.atomarrow.util.DateUtil;
/**
 * 周bean
 * @author Administrator
 *
 */
public class WeekBean implements Option{

	private int year;
	private int week;//第几周，以周末为准
	private Date startDay;//周第一天
	private Date endDay;//周最后一天
	private Date cycleStartDay;
	private Date cycleEndDay;

	public WeekBean(int year, int week, Date mondayOfThisWeek,
			Date sunDayOfThisWeek) {
		this.year=year;
		this.week=week;
		this.startDay=mondayOfThisWeek;
		this.endDay=sunDayOfThisWeek;
	}
	public Date getCycleStartDay() {
		return cycleStartDay;
	}
	public void setCycleStartDay(Date cycleStartDay) {
		this.cycleStartDay = cycleStartDay;
	}
	public Date getCycleEndDay() {
		return cycleEndDay;
	}
	public void setCycleEndDay(Date cycleEndDay) {
		this.cycleEndDay = cycleEndDay;
	}
	public int getWeek() {
		return week;
	}
	public void setWeek(int week) {
		this.week = week;
	}
	public Date getStartDay() {
		return startDay;
	}
	/**
	 * 周第一天
	 * @return
	 */
	public void setStartDay(Date startDay) {
		this.startDay = startDay;
	}
	public Date getEndDay() {
		return endDay;
	}
	/**
	 * 周最后一天
	 * @return
	 */
	public void setEndDay(Date endDay) {
		this.endDay = endDay;
	}
	public int getYear() {
		return year;
	}
	public void setYear(int year) {
		this.year = year;
	}
	/**
	 * 如果开始时间在周期开始时间之前则返回周期的开始时间，否则返回开始时间
	 * @return
	 */
	public Date getStartDayClever() {
		if(cycleStartDay!=null&&cycleStartDay.after(startDay)){
			return cycleStartDay;
		}
		return startDay;
	}
	/**
	 * 如果结束时间在周期结束时间之后则返回周期的截止时间，否则返回结束时间
	 * @return
	 */
	public Date getEndDayClever() {
		if(cycleEndDay!=null&&cycleEndDay.before(endDay)){
			return cycleEndDay;
		}
		return endDay;
	}
	public Boolean getIsCurrentWeek() {
		Date date = new Date();
		return date.after(DateUtil.HHmmssTo000000(startDay)) && date.before(DateUtil.HHmmssTo235959(endDay));
	}
	@Override
	public Object getOptionValue() {
		return this.week;
	}
	@Override
	public Object getOptionText() {
		// TODO Auto-generated method stub
		return "第"+this.week+"周";
	}
	
	
	
}
